package com.yunhe.authority.service.wechat.impl;

import com.yunhe.authority.domain.wechat.WechatLoginRecord;
import com.yunhe.authority.repository.wechat.WechatLoginRecordRepository;
import com.yunhe.authority.service.wechat.WechatLoginRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhengbo
 * @date 2021/9/9 10:32
 */
@Service
@Slf4j
public class WechatLoginRecordServiceImpl implements WechatLoginRecordService {

    @Autowired
    private WechatLoginRecordRepository wechatLoginRecordRepository;

    @Override
    public WechatLoginRecord save(WechatLoginRecord wechatLoginRecord) {
        return wechatLoginRecordRepository.save(wechatLoginRecord);
    }

    @Override
    public List<WechatLoginRecord> findByOpenid(String openid) {
        return wechatLoginRecordRepository.findByOpenid(openid);
    }

    @Override
    public List<WechatLoginRecord> findByUnionid(String unionid) {
        return wechatLoginRecordRepository.findByUnionid(unionid);
    }

    @Override
    public WechatLoginRecord findByPhone(String phone) {
        return wechatLoginRecordRepository.findByPhone(phone);
    }

    @Override
    public WechatLoginRecord findByUserIdAndOpenid(Long userId, String openid) {
        return wechatLoginRecordRepository.findByUserIdAndOpenid(userId, openid);
    }
}
